<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: google_merchant.php 50 2013-09-21 11:57:14Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 50 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-21 11:57:14 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

require('includes/application_top.php');

if ($_GET['action']) {
	$configuration = $db->db_query("SELECT
										configuration_key,
										configuration_id,
										configuration_value,
										use_function,
										set_function
									FROM
										".TABLE_CONFIGURATION."
									WHERE
										configuration_group_id = '28'
									ORDER BY
										sort_order");

	while(!$configuration->EOF) {
		$db->db_query("UPDATE ".TABLE_CONFIGURATION." SET configuration_value = '".$_POST[$configuration->fields['configuration_key']]."' WHERE configuration_key = '".$configuration->fields['configuration_key']."'");
		$configuration->MoveNext();
	}
	redirect(href_link('google_merchant.php'));
}

$cfg_group = $db->db_query("SELECT
								configuration_group_title
							FROM
								".TABLE_CONFIGURATION_GROUP."
							WHERE
								configuration_group_id = '28'");
								
require_once(DIR_WS_INCLUDES.'/xajax/xajax_core/xajax.inc.php');
$xajax = new xajax();
require(DIR_FS_ADMIN.DIR_WS_INCLUDES.'xajax/xajax.google_global.php');
require(DIR_FS_ADMIN.DIR_WS_INCLUDES.'xajax/xajax.misc.php');
if(!empty($xajax))
	$xajax->processRequest();
require(DIR_WS_INCLUDES.'metatag.php');
if(!empty($xajax))
	$xajax->printJavascript();
?>
</head>
<body>
<?php require(DIR_WS_INCLUDES.'header.php'); ?>
<div id="wrapper">
<table class="outerTable" cellpadding="0" cellspacing="0">
	<tr>
    <td class="columnLeft2" width="<?php echo BOX_WIDTH; ?>" valign="top">
		<?php require(DIR_WS_INCLUDES.'column_left.php'); ?>
	</td>
    <td class="boxCenter" valign="top">
    	<table width="100%" cellspacing="0" cellpadding="2">
      		<tr>
        		<td>
          			<table class="table_pageHeading">
  						<tr>
		    				<td class="pageHeading" colspan="2">
		    					<p>
		    					<?php echo ($cfg_group->_numOfRows ? $cfg_group->fields['configuration_group_title'].' - ': ''); ?>SEO:mercari Konfiguration</p>
		    				</td>
		  				</tr>
					</table>
				</td>
      		</tr>
 			<tr>
        	<td class="main">
        		<table width="100%">
          			<tr>
            			<td valign="top" align="right">
							<?php echo draw_form('google_merchant', 'google_merchant.php', 'action=save'); ?>
            				<table width="100%"  border="0" cellspacing="0" cellpadding="4">
           						<tr>
      								<td align="right" colspan="2">
	    								<button type="submit" class="button" onclick="this.blur();"><?php echo BUTTON_SAVE ?></button>
	    							</td>
      							</tr>
								<?php							
								$configuration = $db->db_query("SELECT
																	configuration_key,
																	configuration_id,
																	configuration_value,
																	use_function,
																	set_function
																FROM
																	".TABLE_CONFIGURATION."
																WHERE
																	configuration_group_id = '28'
																ORDER BY
																	sort_order");
								$i=1;
								while(!$configuration->EOF) {
									if (not_null($configuration->fields['use_function'])) {
										$use_function = $configuration->fields['use_function'];
										if (preg_match('/->/', $use_function)) {
											$class_method = explode('->', $use_function);
											if (!is_object(${$class_method[0]})) {
												include(DIR_WS_CLASSES.$class_method[0].'.php');
												${$class_method[0]} = new $class_method[0]();
											}
											$cfgValue = call_function($class_method[1], $configuration->fields['configuration_value'], ${$class_method[0]});

										} else
											$cfgValue = call_function($use_function, $configuration->fields['configuration_value']);

									} else
										$cfgValue = $configuration->fields['configuration_value'];

									if (((!$_GET['cID']) || (@$_GET['cID'] == $configuration->fields['configuration_id'])) && (!$cInfo) && (substr($_GET['action'], 0, 3) != 'new')) {
										$cfg_extra = $db->db_query("SELECT
																		configuration_key,
																		configuration_value,
																		date_added,
																		last_modified,
																		use_function,
																		set_function
																	FROM
																		".TABLE_CONFIGURATION."
																	WHERE
																		configuration_id = '".$configuration->fields['configuration_id']."'");

										$cInfo = new objectInfo($cfg_extra->fields);
									}
									if ($configuration->fields['set_function'])
										eval('$value_field = '.$configuration->fields['set_function'].'"'.htmlspecialchars($configuration->fields['configuration_value']).'");');
									else
										$value_field = draw_input_field($configuration->fields['configuration_key'], $configuration->fields['configuration_value'],'size="40" id="'.$configuration->fields['configuration_key'].'"');

									if(strstr($value_field, 'configuration_value'))
										$value_field = str_replace('configuration_value', $configuration->fields['configuration_key'], $value_field);

									if ($i % 2 == 0)
										$f = '';
									else
										$f = 'dataTableRow';
									echo '	<tr class="'.$f.'" >
												<td width="30%" valign="top" style="border-top: 1px solid #ccc">
													<b>'.constant(strtoupper($configuration->fields['configuration_key'].'_TITLE')).'</b>
												</td>
												<td valign="top" align="left" style="border-top: 1px solid #ccc">
													<table width="100%"  border="0" cellspacing="0" cellpadding="2">
														<tr>
															<td>'.$value_field.'</td>
														</tr>';
									if(strtoupper($configuration->fields['configuration_key']) == 'GOOGLE_MERCHANT_GLOBAL')
										echo '<tr><td id="google_taxonomy"></td></tr>';
									echo			'</table>
													<p>'.constant(strtoupper( $configuration->fields['configuration_key'].'_DESC')).'</p>
												</td>
											</tr>';
									$i++;
									$configuration->MoveNext();
								}
								?>
            				</table>
							<button type="submit" class="button" onclick="this.blur();"><?php echo BUTTON_SAVE ?></button></form>
            			</td>
          			</tr>
        		</table>
        	</td>
      	</tr>
    </table>
   </td>
  </tr>
</table>
<script type="text/javascript">
	xajax_get_new_dropdown();
</script>
</div>
<?php require(DIR_WS_INCLUDES.'footer.php'); ?>
</body>
</html>
<?php require(DIR_WS_INCLUDES.'application_bottom.php'); ?>